﻿using MyCode.Project.Domain.Message.Request.Activity;
using MyCode.Project.Domain.Message.Request.Clerk;
using MyCode.Project.Domain.Message.Response.Activity;
using MyCode.Project.Domain.Message.Response.Shop;
using MyCode.Project.Domain.Message.Response.User;
using MyCode.Project.Infrastructure.Common;
using MyCode.Project.Services;
using System;
using System.Collections.Generic;
using System.Web.Http;

namespace MyCode.Project.WebApi.Areas.Wechat.Controllers
{
    /// <summary>
    ///分销活动设置  相关
    /// </summary>
    public class ActivitySetController : BaseWechatController
    {
        private IActivitySetService _activitySetService;
        private IActivityService _activityService;

        /// <summary>
        /// 初始化一个<see cref="ActivityController"/>类型的实例
        /// </summary>
        public ActivitySetController(IActivitySetService activitySetService
            , IActivityService activityService)
        {
            _activitySetService = activitySetService;
            _activityService = activityService;
        }

        #region GetShareMemberPageList 获取有分销资格的会员
        /// <summary>
        /// 设置分销资格--获取有分销资格的会员分页列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public PageResult<ShareMemberResp> GetShareMemberPageList(PagedSearch<ShareMemberReq> request)
        {
            request.Condition.ShopId = request.Condition.ShopId == null ? this.CurrentLogin.ShopId.Value : request.Condition.ShopId;
            return _activitySetService.GetShareMemberPageList(request);
        }
        #endregion

        #region GetAllMemberPageList 获取店铺所有会员
        /// <summary>
        /// 设置分销资格--获取店铺所有会员分页列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public PageResult<ShareMemberResp> GetAllMemberPageList(PagedSearch<ShareMemberReq> request)
        {
            request.Condition.ShopId = request.Condition.ShopId == null ? this.CurrentLogin.ShopId.Value : request.Condition.ShopId;
            return _activitySetService.GetAllMemberPageList(request);
        }
        #endregion 

        #region SetShareMembers 提交选择的会员信息
        /// <summary>
        /// 设置分销资格--确认选择 提交会员信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public void SetShareMembers(IsShareMemberReq request)
        {
            request.ShopId = request.ShopId == null ? this.CurrentLogin.ShopId.Value : request.ShopId;
            _activitySetService.SetShareMembers(request,this.CurrentLogin);
        }
        #endregion

        #region CancelShareMember 取消分销资格
        /// <summary>
        /// 设置分销资格--取消分销资格
        /// </summary>
        /// <param name="id">数据主键</param>
        /// <returns></returns>
        [HttpGet]
        public void CancelShareMember(Guid id)
        {           
            _activitySetService.CancelShareMember(id);
        }
        #endregion 

        #region GetActivityProfitList 获取店铺分佣比例列表
        /// <summary>
        /// 设置分佣比例--获取店铺分佣比例列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public List<ActivityProfitResp> GetActivityProfitList(ActivityProfitReq request)
        {
            request.ShopId = request.ShopId == null ? this.CurrentLogin.ShopId.Value : request.ShopId;
            return _activitySetService.GetActivityProfitList(request);
        }
        #endregion

        #region SetActivityProfit 设置店铺分佣比例
        /// <summary>
        /// 设置分佣比例--保存店铺分佣比例
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public void SetActivityProfit(SetActivityProfitReq request)
        {
            request.ShopId = request.ShopId == null ? this.CurrentLogin.ShopId.Value : request.ShopId;
            _activitySetService.SetActivityProfit(request,this.CurrentLogin);
        }
        #endregion

        #region GetClerkProfitTotal 店员活动数据-获取本人获利来源
        /// <summary>
        /// 店员活动数据-获取本人获利来源
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public ClerkProfitReq GetClerkProfitTotal(PagedSearch<UserProfitResp> request)
        {
            return _activitySetService.GetClerkProfitTotal(request, this.CurrentLogin);
        }
        #endregion

        #region GetClerkProfitDetail 店员活动数据-获取本人获利明细
        /// <summary>
        /// 店员活动数据-获取本人获利明细
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public PageResult<UserProfitDetailReq> GetClerkProfitDetail(PagedSearch<UserProfitResp> request)
        {
            return _activityService.GetUserProfitDetail(request, this.CurrentLogin);
        }
        #endregion

        #region GetCustomerProfitTotal 加盟商活动数据-获取本人分利数据 AllSettledResp
        /// <summary>
        /// 加盟商活动数据-获取本人分利数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public AllUserProfitReq GetCustomerProfitTotal(PagedSearch<CusProfitResp> request)
        {
            return _activitySetService.GetCustomerProfitTotal(request, this.CurrentLogin);
        }
        #endregion

        #region SetSettled 加盟商活动数据-结款
        /// <summary>
        /// 加盟商活动数据-结款
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public void SetSettled(SetSettledReq request)
        {
            _activitySetService.SetSettled(request, this.CurrentLogin);
        }
        #endregion

        #region GetCustomerSettlePageList 加盟商活动数据-获取本人结算数据 
        /// <summary>
        /// 加盟商活动数据-获取本人结算数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public PageResult<AllSettledResp> GetCustomerSettlePageList(PagedSearch<CusProfitResp> request)
        {
            return _activitySetService.GetCustomerSettlePageList(request, this.CurrentLogin);
        }
        #endregion
    }
}

